package com.extension.company.view.login;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.extension.company.admin.R;
import com.extension.company.common.mvp.BaseBarActivity;
import com.extension.company.contract.login.LoginContract;
import com.extension.company.model.api.Urls;
import com.extension.company.presenter.login.LoginPresenter;
import com.extension.company.view.main.MainActivity;
import com.extension.company.view.webview.WebViewActivity;

import butterknife.BindView;

public class LoginActivity extends BaseBarActivity<LoginContract.View, LoginPresenter>
		implements LoginContract.View, View.OnClickListener {

	@BindView(R.id.tv_loginpro)
	TextView tv_loginpro;

	@BindView(R.id.tv_cancel)
	TextView tv_cancel;

	@BindView(R.id.btn_login)
	Button btn_login;

	public static void startActivity(Activity activity) {
		Intent intent = new Intent(activity, LoginActivity.class);
		activity.startActivity(intent);
	}

	@Override
	protected void initData() {

	}

	@Override
	protected void initListener() {
		tv_cancel.setOnClickListener(this);
		tv_loginpro.setOnClickListener(this);
		btn_login.setOnClickListener(this);
	}

	@Override
	public int getMainLayout() {
		return R.layout.login;
	}

	@Override
	public LoginContract.View createView() {
		return this;
	}

	@Override
	public LoginPresenter createPresenter() {
		return new LoginPresenter();
	}

	@Override
	public void showLoading() {
		Log.d("zwk", "获取mode数据");

	}

	@Override
	public void hideLoading() {
		Log.d("zwk", "我还是你大爷");
	}

	@Override
	public void onError(Throwable throwable) {

	}

	@Override
	public void onClick(View view) {
		switch (view.getId()) {
			case R.id.tv_loginpro:
				WebViewActivity.startActivity(this, "赚圈用户协议及隐私保护", Urls.LoginUrl);
				break;
			case R.id.tv_cancel:
				finish();
				break;
			case R.id.btn_login:

				presenter.login(LoginActivity.this);

				break;
			default:
				break;
		}
	}

	@Override
	public void WXLoginSuccess(String id) {  // 授权成功

		Intent intent = new Intent(this, MainActivity.class);
		startActivity(intent);
		finish();

	}

	@Override
	public void WXLoginFaile() {  // 授权成功
		Log.d("zwk", "授权失败");
	}
}
